]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowManager: Implement MetaDisplay::init-xserver hook
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 14 Nov 2019 22:56:42 +0000 (23:56 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Sat, 29 Feb 2020 17:58:55 +0000 (18:58 +0100)
We do spawn gsd-xsettings, and watch its name before notifying on the
given task, so the mutter bits can proceed with X11 startup.

One notable change is that we only start gsd-xsettings, instead of the
generic gnome-session-x11-services target. We do so as we have to wait
on a dbus name to appear in order to deem the initialization done, and
making it all depend on gsd-xsettings seems tidier.

Less notably, we also use ::shutdown-xserver to shutdown the related
services. Its major benefit is that it'd allow us to ensure the olderly
shutdown of those services, but it's unused at the moment.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/836

js/ui/windowManager.js

index 53f1845615f504d7cbe883dc3b16eafc20a50ecd..d02d2e183b9248a39148bff9bf071b03ed7997bb 100644 (file)
@@ -896,13 +896,36 @@ var WindowManager = class {
             }
         });
 
-        global.display.connect('x11-display-opened', () => {
+        global.display.connect('init-xserver', (display, task) => {
             IBusManager.getIBusManager().restartDaemon(['--xim']);
-            Shell.util_start_systemd_unit('gnome-session-x11-services.target', 'fail');
+            Shell.util_start_systemd_unit('gsd-xsettings.target', 'fail');
+
+            /* Leave this watchdog timeout so don't block indefinitely here */
+            let timeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 5, () => {
+                Gio.DBus.session.unwatch_name(watchId);
+                task.return_boolean(false);
+                timeoutId = 0;
+                return GLib.SOURCE_REMOVE;
+            });
+
+            /* When gsd-xsettings daemon is started, we are good to resume */
+            let watchId = Gio.DBus.session.watch_name(
+                'org.gnome.SettingsDaemon.XSettings',
+                Gio.BusNameWatcherFlags.NONE,
+                () => {
+                    Gio.DBus.session.unwatch_name(watchId);
+                    if (timeoutId > 0) {
+                        task.return_boolean(true);
+                        GLib.source_remove(timeoutId);
+                    }
+                },
+                null);
+            return true;
         });
-        global.display.connect('x11-display-closing', () => {
-            Shell.util_stop_systemd_unit('gnome-session-x11-services.target', 'fail');
+        global.display.connect('shutdown-xserver', (display, task) => {
+            Shell.util_stop_systemd_unit('gsd-xsettings.target', 'fail');
             IBusManager.getIBusManager().restartDaemon();
+            task.return_boolean(true);
         });
 
         Main.overview.connect('showing', () => {